package com.jiangchuang.utils;

import com.jiangchuang.domain.entity.User;
import com.jiangchuang.domain.entity.UserAdmin;

public class UserContextUtils {
    private static ThreadLocal<UserAdmin> userThreadLocal = new ThreadLocal<>();

    public static void setCurrentUser(UserAdmin user){
        userThreadLocal.set(user);
    }

    public static UserAdmin getCurrentUser(){
        return userThreadLocal.get();
    }

    public static Integer getCurrentUserId(){

        return getCurrentUser().getId();
//        return 679386;
    }

    public static void remove(){
        userThreadLocal.remove();
    }
}